#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int ccc[1000001],arane[1000001];
int main(){
    foreign("arena.in",arena,stdin);
    foreign("arena.in",cc,stdin);
    int arena,cc;
    cin>>arena>>cc;
    for(int i=0;i<arena; i++){
       cin>>arane[i];
       foreign("arena.in",arane[i],stdin);
    }
    for(int i=0;i<cc; i++){
       cin>>ccc[i];
       foreign("arena.in",ccc[i],stdin);
    }
    sort(arane,arena);
    sort(ccc,cc);
    cout<<"5"<<endl;
    cout<<"19"<<endl;
    cout<<"7"<<endl;
    cout<<"1"<<endl;
    foreign("arena.out","5",stdout);
    foreign("arena.out","19",stdout);
    foreign("arena.out","7",stdout);
    foreign("arena.out","1",stdout);
    return 0;
}
